<!--
 * @Description: 
 * @Autor: Zhu_liangyu
 * @Date: 2020-05-09 10:52:56
--> 
<template>
  <div style="margin: -24px -24px 0px;">
    <div class="page-header" v-if="!$route.meta.hiddenHeaderContent">
      <a-page-header
        @back="() => $router.push({'path':backUrl})"
        :title="title"
        :subTitle="subTitle"
        v-if="backUrl"
      ></a-page-header>
      <a-page-header v-else :title="title" :subTitle="subTitle"></a-page-header>
    </div>
    <div class="page-content">
      <router-view ref="content"></router-view>
      <!-- <router-view v-if="!$route.meta.keepAlive" ref="content" /> -->
    </div>
  </div>
</template>

<script>
export default {
  name: "PageView",
  data() {
    return {
      title: null,
      subTitle: null,
      backUrl: null
    };
  },
  mounted() {
    this.getPageMeta();
  },
  updated() {
    this.getPageMeta();
  },
  methods: {
    getPageMeta() {
      var content = this.$refs.content;
      if (content) {
        //获取子页面的数据
        this.title = content.title || this.$route.meta.title;
        this.subTitle = content.subTitle || this.$route.meta.subTitle;
        this.backUrl = content.backUrl;
      }
    }
  }
};
</script>

<style lang="scss">
.page-header {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
}

.page-content {
  margin: 24px 24px 0;
}
</style>